/**
 * 
 */
package com.nari.basic.service;

import java.util.List;

import com.nari.basic.model.IMenu;
import com.nari.coreframe.service.IGenericService;
import com.nari.platform.components.dhtmltree.DhtmlTreeNode;
import com.nari.platform.model.ResponseMsg;

/**
 * 
 * @author Xiaopeng
 * @date 2013-7-18
 */
public interface IMenuService extends IGenericService<IMenu, String> {
	
	/**
	 * 查询系统所有菜单
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-7-23
	 */
	public List<IMenu> queryAllMenusInOrder() throws Exception;

	/**
	 * 通过角色唯一识别码查询其对应的菜单列表
	 * @param roleUIDs 角色唯一识别码
	 *   格式：XXX,XXX,XXX
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-7-22
	 */
	public List<IMenu> queryUserMenuByRoleUIDs(String roleUIDs) throws Exception;
	
	/**
	 * 查询菜单根节点，并过滤出权限菜单
	 * @param authorityMenuList 权限菜单，默认无权限过滤
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-7-23
	 */
	public List<IMenu> queryFirstLevelMenu(List<IMenu> authorityMenuList) throws Exception;
	
	/**
	 * 根据父菜单ID查询子菜单节点，并过滤出权限菜单（需要情况下）
	 * @param pMenuID 若父菜单不存在，则查询根节点
	 * @param authorityMenuList 权限菜单，默认无权限过滤
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-7-23
	 */
	public List<IMenu> queryChildMenuByParent(String pMenuID, List<IMenu> authorityMenuList) throws Exception;
	
	/**
	 * 将菜单列表转化为树节点
	 * @param menuList
	 * @param ifLeafMenu 标识菜单节点是否为叶子节点，默认非叶子节点
	 * @return
	 * @author Xiaopeng
	 * @date 2013-7-23
	 */
	public List<DhtmlTreeNode> formatMenuListToTreeNodes(List<IMenu> menuList, Boolean ifLeafMenu);
	
	/**
	 * 通过菜单名称模糊查询
	 * @param menuName
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-7-24
	 */
	public List<IMenu> queryByMenuNameLike(String menuName) throws Exception;
	
	/**
	 * 菜单项新增或修改
	 * @param menu
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-7-24
	 */
	public ResponseMsg saveOrUpdateMenuItem(IMenu menu) throws Exception;
	
	/**
	 * 通过父菜单ID统计其子菜单的个数
	 * @param pMenuID
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-7-24
	 */
	public int countChildrenByPMenuID(String pMenuID) throws Exception;
	
	/**
	 * 通过角色唯一标识查询角色菜单授权树
	 * @param roleUID 角色唯一标识
	 * @param parentMenuID 树菜单的父节点，若为空表示查询顶层树节点
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-7-30
	 */
	public DhtmlTreeNode queryAuthorityTreeByRole(String roleUID, 
			String parentMenuID) throws Exception;
	
	/**
	 * 保存角色菜单授权
	 * @param roleUID
	 * @param menuIDList 授权菜单列表
	 * 	格式：XXX,XXX,XXX
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-7-30
	 */
	public ResponseMsg saveRoleMenuAuthority(String roleUID, String menuIDList) throws Exception;
	
	/**
	 * 通过系统访问的URL查询其对应的菜单位置
	 * @param visitUrl
	 * @return 返回从顶层菜单依次到底层菜单的列表
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2014-3-25
	 */
	public List<IMenu> queryMenuTraceByVisitUrl(String visitUrl) throws Exception;
}
